/*
 * Author  : Pallab
 * Program : 2761.cxx
 * 
 * Tue Jul 17 17:05:15 2012
 *
 * I have not failed, I have just found 10000 ways that won't work.
 *
 */
 
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line putchar('\n')

template<class T1>
inline void debug(T1 _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
template< class T1>
inline void debug(T1 _array,int _size) {
    cout<<"[";
    for (int i=0; i<_size; ++i) {
        cout<<' '<<_array[i];
    }
    puts(" ]");
}

inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}
inline void wait( double seconds ) {
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while ( clock() < endtime ) {
        ;
    }
}
namespace solve{
bool runtimecheck;
bool delim (char c) {
	return c == ' ';
}
 
bool is_op (char c) {
	return c=='+' || c=='-' || c=='*' || c=='/' || c=='%';
}
 
int priority (char op) {
	return
		op == '+' || op == '-' ? 1 :
		op == '*' || op == '/' || op == '%' ? 2 :
		-1;
}
 
void process_op (vector<int> & st, char op) {
	int r = st.back();  st.pop_back();
	int l = st.back();  st.pop_back();
	switch (op) {
		case '+':  st.push_back (l + r);  break;
		case '-':  st.push_back (l - r);  break;
		case '*':  st.push_back (l * r);  break;
		case '/':  if( r==0 ){
				 runtimecheck=1; 
			   }
    	  		   else{
    	  		   	st.push_back (l / r);  
    	  		   }
			   break;
		case '%':  st.push_back (l % r);  break;
	}
}
 
int calc (string & s) {
	vector<int> st;
	vector<char> op;
	runtimecheck=0;
	for (size_t i=0; i<s.length() && !runtimecheck; ++i)
		if (!delim (s[i]))
			if (s[i] == '(')
				op.push_back ('(');
			else if (s[i] == ')') {
				while (op.back() != '(' && !runtimecheck )
					process_op (st, op.back()),  op.pop_back();
				op.pop_back();
			}
			else if (is_op (s[i])) {
				char curop = s[i];
				while (!op.empty() && priority(op.back()) >= priority(s[i]) && !runtimecheck)
					process_op (st, op.back()),  op.pop_back();
				op.push_back (curop);
			}
			else {
				string operand;
				while (s[i] >= 'a' && s[i] <= 'z' || isdigit (s[i]))
					operand += s[i++];
				--i;
				if (isdigit (operand[0]))
					st.push_back (atoi (operand.c_str()));
				else
					puts("error");
			}
	while (!op.empty() && !runtimecheck )
		process_op (st, op.back()),  op.pop_back();
	return st.back();
	}
}
string ss="+-*/";
bool go(int at, vector<int> vi, string str, int num){
	if( at<0 ){
		return solve::calc(str) == num && solve::runtimecheck==0 ? true : false ;
	}

	fo(i,4){
		str[ vi[at] ]=ss[i];
		bool var = go( at-1, vi, str, num );
		if( var ==true )return true;
	}
	return false;
}

inline void main2(string str, int num){
	vector<int> vi;
	int ln = LN(str);
	fo(i,ln){
		if( str[i]=='?' )
			vi.pb( i );
	}
	bool nice=false;
	if( SZ(vi) ){
		nice= go(SZ(vi)-1, vi, str, num) ;
	}
	else{
	    	nice = solve::calc(str) == num ? true : false ;
	}
	puts( ( nice ? "yes" : "no" ) );
}
int main(){
	int nn;
	CI(nn);
	string lines;
	int num;
	fo(i,nn){
		cin>>lines;
		cin>>num;
		main2(lines, num );
	}	
	
return 0;
}
